package com.zcs.thread.created;

/**
 * @author zcs
 * @since 2023/4/6
 */
public class MyRunnable {

    public static void main(String[] args) {
        //创建线程对象，通过线程对象来开启我们的线程，代理
        Thread thread1 = new Thread(new ThreadA());
        thread1.setName("线程1");
        Thread thread2 = new Thread(new ThreadB());
        thread2.setName("线程2");

        thread1.start();
        thread2.start();

    }

    static class ThreadA implements Runnable {

        @Override
        public void run() {
            for (int i = 0; i < 20; i++) {
                System.out.println(Thread.currentThread().getName() + " : " + i);
            }
        }
    }

    static class ThreadB implements Runnable {

        @Override
        public void run() {
            for (int i = 0; i < 20; i++) {
                System.out.println(Thread.currentThread().getName() + " : " + i);
            }
        }
    }
}
